{% extends "forms-side.html" %}

{% load forms common %}

{% block extrahead %}
{{ form.media }}
{% endblock %}

{% block title %}OS Group {{ osgroup }} {% endblock %}

{% block content_title %}OS Group Information{% endblock %}

{% block breadcrumbs %}{{ block.super }} &rsaquo; <a href="{% url 'os_list' %}">Operating Systems</a> &rsaquo; <a href="{% url 'osgroup_list' %}">Groups</a> &rsaquo; {{ osgroup }} {% endblock %}

{% block content %}

<div class="module">
    <h2>{{ osgroup }} Details</h2>
    <table>
        <tr>
            <td>Name</td><td> {{ osgroup.name }} </td>
        </tr>
    </table>
</div>

<div class="module">
    <h2>Operating Systems linked to OS Group {{ osgroup }}</h2>
    <table>
        <thead>
        <tr>
            <th>OS Name</th>
        </tr>
        </thead>
        {% for repo in osgroup.os_set.select_related %}
        <tr class="{% cycle 'row1' 'row2' %}">
            <td><a href="{{ repo.get_absolute_url }}">{{ repo }}</a></td>
        </tr>
        {% endfor %}
    </table>
</div>

{% if user.is_authenticated %}
    {% if perms.is_admin %}
    <div class="module">
        <h2>Actions</h2>
        <a class="brick" href="{% url 'osgroup_delete' osgroup.id %}">Delete this OS Group</a>
        <div class="clearbrick"></div>
        <br />
    </div>
    {% endif %}
{% endif %}

<div class="module">
    {% if osgroup.repos.count == 0 %}
    <h2>{{ osgroup }} has no Repositories</h2>
{% else %}
    <h2>{{ osgroup }} Repositories</h2>
    {% gen_table osgroup.repos.select_related %}
{% endif %}
</div>

{% if user.is_authenticated %}
    {% if perms.is_admin %}
    <div class="module">
        <h2>Modify {{ osgroup }} repos</h2>
            <form action={{ request.path }} method="post">{% csrf_token %}
            {% form_as_div form %}
            <br /><input type="submit" value="Save" /> 
            </form>
    </div>
    {% endif %}
{% endif %}

{% endblock %}

